import os

# 定义一个简单的数据库，用于存储收入和支出记录
database = {
    "incomes": [],
    "expenses": []
}

# 函数：记录收入
def record_income(amount, description):
    database["incomes"].append({"amount": amount, "description": description})
    print(f"收入记录成功：{description} - {amount}")

# 函数：记录支出
def record_expense(amount, description):
    database["expenses"].append({"amount": amount, "description": description})
    print(f"支出记录成功：{description} - {amount}")

# 函数：显示所有收入
def show_incomes():
    print("所有收入记录：")
    for income in database["incomes"]:
        print(f"{income['description']} - {income['amount']}")

# 函数：显示所有支出
def show_expenses():
    print("所有支出记录：")
    for expense in database["expenses"]:
        print(f"{expense['description']} - {expense['amount']}")

# 主函数：命令行交互
def main():
    while True:
        print("\n欢迎使用财务管理系统")
        print("1. 记录收入")
        print("2. 记录支出")
        print("3. 显示所有收入")
        print("4. 显示所有支出")
        print("5. 退出")
        
        choice = input("请选择一个操作：")
        
        if choice == "1":
            amount = float(input("请输入收入金额："))
            description = input("请输入收入描述：")
            record_income(amount, description)
        elif choice == "2":
            amount = float(input("请输入支出金额："))
            description = input("请输入支出描述：")
            record_expense(amount, description)
        elif choice == "3":
            show_incomes()
        elif choice == "4":
            show_expenses()
        elif choice == "5":
            print("感谢使用财务管理系统。再见！")
            break
        else:
            print("无效的输入，请重新选择。")

if __name__ == "__main__":
    main()